import java.util.ArrayList;
import java.util.List;

public class L1656 {

    String[] container;
    int ptr = 1;
    int n;
    public L1656(int n) {
        this.n = n;
        container = new String[n];
    }

    public List<String> insert(int idKey, String value) {
        List<String> res = new ArrayList<>();
        if (ptr > n) return res;
        container[idKey-1] = value;
        if (idKey == ptr){
            while (container[idKey-1]!=null){
                res.add(new String(container[idKey-1]));
                idKey++;
                if (idKey>n) break;
            }
            ptr = idKey;
        }
        return res;
    }

    public static void main(String[] args) {
        L1656 os= new L1656(1);
        System.out.println(os.insert(1, "ccccc")); // 插入 (3, "ccccc")，返回 []
    }
}
